;~ pack all in one - will not work on x64 systems because of another opcode
Func _Base64Encode($Data, $LineBreak = 76)
	Local $Opcode = "0x5589E5FF7514535657E8410000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392B2F005A8B5D088B7D108B4D0CE98F0000000FB633C1EE0201D68A06880731C083F901760C0FB6430125F0000000C1E8040FB63383E603C1E60409C601D68A0688470183F90176210FB6430225C0000000C1E8060FB6730183E60FC1E60209C601D68A06884702EB04C647023D83F90276100FB6730283E63F01D68A06884703EB04C647033D8D5B038D7F0483E903836DFC04750C8B45148945FC66B80D0A66AB85C90F8F69FFFFFFC607005F5E5BC9C21000"
	Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")
	DllStructSetData($CodeBuffer, 1, $Opcode)
 	$Data = Binary($Data)
	Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]")
	DllStructSetData($Input, 1, $Data)
	$LineBreak = Floor($LineBreak / 4) * 4
	Local $OputputSize = Ceiling(BinaryLen($Data) * 4 / 3) 
	$OputputSize = $OputputSize + Ceiling($OputputSize / $LineBreak) * 2 + 4
	Local $Ouput = DllStructCreate("char[" & $OputputSize & "]")
	DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer),"ptr", DllStructGetPtr($Input), "int", BinaryLen($Data), "ptr", DllStructGetPtr($Ouput), "uint", $LineBreak)
	Return DllStructGetData($Ouput, 1)
EndFunc
func ReplaceStringWithExt($ext,$open_tag,$close_tag)
	$arr=StringRegExp($content,'<.*\.'&$ext&'.*>',3)
	for $line in $arr
		if $ext='css' then $afilename=StringRegExp($line,'(?i)href="(.*)(?-i)"\s',3)
		if $ext='js' then $afilename=StringRegExp($line,'(?i)src="(.*)(?-i)"',3)		
		$replacetext=FileRead(@ScriptDir&"\"&$afilename[0])
		$replacetext=$open_tag&@CRLF&$replacetext&$close_tag		
		$content=StringReplace($content,$line,$replacetext)
	next
	if $ext='css' then;-if css parse images 2
		$arr2=StringRegExp($content,"\(\.\.\/(.*\.png)",3)				
		if @Error=0	then
			for $line in $arr2
				$content=StringReplace($content,"(../"&$line&")",'(data:image/png;base64,'&_Base64Encode(FileRead(@ScriptDir&"\"&$line),0)&') ');
			Next
		endif
		$arr3=StringRegExp($content,"\(\.\.\/(.*\.gif)",3)
		if @error=0 then
			for $line in $arr3
				$content=StringReplace($content,"(../"&$line&")",'(data:image/gif;base64,'&_Base64Encode(FileRead(@ScriptDir&"\"&$line),0)&') ');
			Next
		EndIf		
	EndIf
EndFunc

if 
$content=FileRead(@ScriptDir&"\"&$cmdline[1])
ReplaceStringWithExt('css','<style>','</style>')
ReplaceStringWithExt('js','<script language="JScript">','</script>')
$name_parts=StringSplit($cmdline[1],".")
$write=FileOpen(@ScriptDir&"\"&$name_parts[1]&".full."&$name_parts[2],2)
;~ clear code tasks
;~ delete comments
$content=StringRegExpReplace($content,'[^\*;]\/\*[\d\D]*?\*\/','')
;~ $content=StringRegExpReplace($content,'\n\s*\/\/.*\n','')
FileWrite($write,$content)